import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex);


let store = new Vuex.Store({
    state:{
      num: 233
    },
    actions:{
      asycnAdd:function(state){
        setTimeout(function(){
          store.commit("add")
        },2000)
      }
    },
    mutations:{
      add:function(state){
        state.num++
      },
      sub:function(state){
        state.num--
      },
    },
    getters:{
        isOddAndEven:function(state){
            return state.num  % 2 ? "奇数" : "偶数"
        }
    }
  });

  export default store;